package Test1;

import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;
import java.util.concurrent.*;

interface A{
    default void func() {
        System.out.println("嘿嘿");
    }
}
class B implements A {

}
public class TestDemo1 {
    public static void main(String[] args) {
        B b = new B();
        b.func();
    }
    public static void main3(String[] args) {
        List<Integer> values = Arrays.asList(1, 3, 5);
        StringJoiner sj = new StringJoiner(",", "（", ")");

        for (Integer value : values) {
            sj.add(value.toString());
        }
        System.out.println(sj);

    }
    public static void main2(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("打印"+i);
                }
            }
        });
    }
    public static void main1(String[] args) throws InterruptedException {
        Exchanger<String> exchanger = new Exchanger<String>();

// ThreadA
        new Thread(new Runnable() {
            @Override
            public void run() {
                String strA = null;
                try {
                    strA = exchanger.exchange("大佬 A 的钥匙");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("A: 获取" + strA);
            }
        },"A").start();

// ThreadB
        new Thread(new Runnable() {
            @Override
            public void run() {
                String strB = null;
                try {
                    strB = exchanger.exchange("大佬 B 的钥匙");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("B: 获取" + strB);
            }
        },"B").start();
    }
}
